<?php

namespace Transaccion\Model\Dao;

use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Sql;
use Transaccion\Model\Dao\GenericDAO;

class DatosIngresoDAO extends GenericDAO {

    protected $dbAdapter;

    /**
     * Nombre de la Tabla
     * @var type string
     */
    protected $tabla = 'datos_ingreso';
    private static $datosIngresoDao;

    /**
     * Configura Adaptador de Base de Datos
     * 
     * @param \Zend\Db\Adapter\Adapter $adapter
     */
    private function __construct(Adapter $adapter) {
        $this->dbAdapter = $adapter;
    }

    /**
     * 
     * @param type $adapter
     * @return instancia de DatosIngresoDao
     * Patron singleton
     */
    public static function getInstance($adapter) {
        if (self::$datosIngresoDao == null) {
            self::$datosIngresoDao = new DatosIngresoDao($adapter);
        }
        return self::$datosIngresoDao;
    }

    public function getRegistro($id) {
        return $this->getRegistroGeneral($id, $this->tabla, $this->dbAdapter);
    }

    public function getRegistroSegunCedula($id) {
           $sql = new Sql($this->dbAdapter);
           $select = $sql->select();
           $select->from($this->tabla);
           $select->where("id_alumno = '" . $id . "'");
           $selectString = $sql->getSqlStringForSqlObject($select);
           $adapter = $this->dbAdapter;
           $results = $adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
           return $results;


       }
}
